package com.ymttest.database.mapping.godmch;

import com.ymttest.database.mapping.MarkupConfigSqlProvider;
import com.ymttest.database.model.MarkupConfig;
import com.ymttest.database.model.MarkupConfigKey;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface MarkupConfigMapper {
    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table markupconfig
     *
     * @mbggenerated Wed Apr 08 16:33:08 CST 2020
     */
    @Insert({
        "insert into markupconfig (agentId, supplierId, ",
        "markupType, percentage, ",
        "decimalType, onSaleType, ",
        "refreshProduct, configStatus, ",
        "createTime, updateTime)",
        "values (#{agentId,jdbcType=INTEGER}, #{supplierId,jdbcType=INTEGER}, ",
        "#{markupType,jdbcType=INTEGER}, #{percentage,jdbcType=DECIMAL}, ",
        "#{decimalType,jdbcType=INTEGER}, #{onSaleType,jdbcType=INTEGER}, ",
        "#{refreshProduct,jdbcType=BIT}, #{configStatus,jdbcType=INTEGER}, ",
        "#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP})"
    })
    int insert(MarkupConfig record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table markupconfig
     *
     * @mbggenerated Wed Apr 08 16:33:08 CST 2020
     */
    @InsertProvider(type=MarkupConfigSqlProvider.class, method="insertSelective")
    int insertSelective(MarkupConfig record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table markupconfig
     *
     * @mbggenerated Wed Apr 08 16:33:08 CST 2020
     */
    @Select({
        "select",
        "agentId, supplierId, markupType, percentage, decimalType, onSaleType, refreshProduct, ",
        "configStatus, createTime, updateTime",
        "from markupconfig",
        "where agentId = #{agentId,jdbcType=INTEGER}",
          "and supplierId = #{supplierId,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="agentId", property="agentId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="supplierId", property="supplierId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="markupType", property="markupType", jdbcType=JdbcType.INTEGER),
        @Result(column="percentage", property="percentage", jdbcType=JdbcType.DECIMAL),
        @Result(column="decimalType", property="decimalType", jdbcType=JdbcType.INTEGER),
        @Result(column="onSaleType", property="onSaleType", jdbcType=JdbcType.INTEGER),
        @Result(column="refreshProduct", property="refreshProduct", jdbcType=JdbcType.BIT),
        @Result(column="configStatus", property="configStatus", jdbcType=JdbcType.INTEGER),
        @Result(column="createTime", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="updateTime", property="updateTime", jdbcType=JdbcType.TIMESTAMP)
    })
    MarkupConfig selectByPrimaryKey(MarkupConfigKey key);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table markupconfig
     *
     * @mbggenerated Wed Apr 08 16:33:08 CST 2020
     */
    @UpdateProvider(type=MarkupConfigSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(MarkupConfig record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table markupconfig
     *
     * @mbggenerated Wed Apr 08 16:33:08 CST 2020
     */
    @Update({
        "update markupconfig",
        "set markupType = #{markupType,jdbcType=INTEGER},",
          "percentage = #{percentage,jdbcType=DECIMAL},",
          "decimalType = #{decimalType,jdbcType=INTEGER},",
          "onSaleType = #{onSaleType,jdbcType=INTEGER},",
          "refreshProduct = #{refreshProduct,jdbcType=BIT},",
          "configStatus = #{configStatus,jdbcType=INTEGER},",
          "createTime = #{createTime,jdbcType=TIMESTAMP},",
          "updateTime = #{updateTime,jdbcType=TIMESTAMP}",
        "where agentId = #{agentId,jdbcType=INTEGER}",
          "and supplierId = #{supplierId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(MarkupConfig record);
    
    
    @Select({
        "select",
        "agentId, supplierId, markupType, percentage, decimalType, onSaleType, refreshProduct, ",
        "configStatus, createTime, updateTime",
        "from markupconfig",
        "where  supplierId = #{supplierId,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="agentId", property="agentId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="supplierId", property="supplierId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="markupType", property="markupType", jdbcType=JdbcType.INTEGER),
        @Result(column="percentage", property="percentage", jdbcType=JdbcType.DECIMAL),
        @Result(column="decimalType", property="decimalType", jdbcType=JdbcType.INTEGER),
        @Result(column="onSaleType", property="onSaleType", jdbcType=JdbcType.INTEGER),
        @Result(column="refreshProduct", property="refreshProduct", jdbcType=JdbcType.BIT),
        @Result(column="configStatus", property="configStatus", jdbcType=JdbcType.INTEGER),
        @Result(column="createTime", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="updateTime", property="updateTime", jdbcType=JdbcType.TIMESTAMP)
    })
    MarkupConfig selectBySupplierId(Integer supplierId);
    
    
    
    @Select({
        "select",
        "agentId, supplierId, markupType, percentage, decimalType, onSaleType, refreshProduct, ",
        "configStatus, createTime, updateTime",
        "from markupconfig ",
        "　 where configStatus=0 and createTime < #{createTime,jdbcType=VARCHAR}   order by  createTime desc ",
        " limit 10 "
    })
    @Results({
        @Result(column="agentId", property="agentId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="supplierId", property="supplierId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="markupType", property="markupType", jdbcType=JdbcType.INTEGER),
        @Result(column="percentage", property="percentage", jdbcType=JdbcType.DECIMAL),
        @Result(column="decimalType", property="decimalType", jdbcType=JdbcType.INTEGER),
        @Result(column="onSaleType", property="onSaleType", jdbcType=JdbcType.INTEGER),
        @Result(column="refreshProduct", property="refreshProduct", jdbcType=JdbcType.BIT),
        @Result(column="configStatus", property="configStatus", jdbcType=JdbcType.INTEGER),
        @Result(column="createTime", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="updateTime", property="updateTime", jdbcType=JdbcType.TIMESTAMP)
    })
    MarkupConfig selectByCreatTime(String creatTime);
}